package com.chouxiaozi.promotion;

import java.util.HashMap;
import java.util.Map;

public class PromotionActivityManager {

   /* public static Map<String, IPromotionStrategy> STRATEGY_MAP = new HashMap<>();

    static {
        STRATEGY_MAP.put("cash", new CashbackStrategy());
        STRATEGY_MAP.put("group", new GroupbuyStrategy());
        STRATEGY_MAP.put("ticket", new TicketStrategy());
        STRATEGY_MAP.put("empty", new EmptyStrategy());
    }*/

    private PromotionActivityManager(){

    }

    public static IPromotionStrategy getInstance(String type) throws IllegalAccessException, InstantiationException {
        /*IPromotionStrategy iPromotionStrategy = STRATEGY_MAP.get(type);
        if(iPromotionStrategy == null){
            return STRATEGY_MAP.get("empty");
        }
        return iPromotionStrategy;*/
        StrategyTypeEnum strategyByType = StrategyTypeEnum.getStrategyByType(type);
        return strategyByType == null ? new EmptyStrategy() : strategyByType.getClazz().newInstance();
    }

}
